{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "7ed3a63b",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using TensorFlow backend.\n",
      "/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
      "  _np_qint8 = np.dtype([(\"qint8\", np.int8, 1)])\n",
      "/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
      "  _np_quint8 = np.dtype([(\"quint8\", np.uint8, 1)])\n",
      "/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:528: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
      "  _np_qint16 = np.dtype([(\"qint16\", np.int16, 1)])\n",
      "/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:529: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
      "  _np_quint16 = np.dtype([(\"quint16\", np.uint16, 1)])\n",
      "/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:530: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
      "  _np_qint32 = np.dtype([(\"qint32\", np.int32, 1)])\n",
      "/usr/local/lib/python3.7/site-packages/tensorflow/python/framework/dtypes.py:535: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n",
      "  np_resource = np.dtype([(\"resource\", np.ubyte, 1)])\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "WARNING: The TensorFlow contrib module will not be included in TensorFlow 2.0.\n",
      "For more information, please see:\n",
      "  * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md\n",
      "  * https://github.com/tensorflow/addons\n",
      "If you depend on functionality not listed there, please file an issue.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "import keras.backend\n",
    "\n",
    "from gernerate_data import load_clas_seg_data\n",
    "import tensorflow as tf\n",
    "from sklearn.metrics import classification_report, precision_recall_curve\n",
    "from keras.utils.np_utils import *\n",
    "from keras.callbacks import LearningRateScheduler\n",
    "from sklearn.metrics import classification_report, auc, roc_curve\n",
    "from models.MTL_IBA import MTL_IBA, MTL_IBA_h3, MTL_IBA_cross, MTL_IBA_cross2, MTL_IBA_cross3\n",
    "from models.MLT_net import MTL_classic\n",
    "from sklearn.preprocessing import LabelBinarizer, label_binarize\n",
    "from utils.losses import dice_coef_loss, dice_coef, dice_coef_loss, focal_tversky, p_r_f1_iou,tversky_loss, binary_crossentropy\n",
    "from keras.losses import categorical_crossentropy, mean_squared_error, binary_crossentropy\n",
    "from keras.callbacks import ReduceLROnPlateau, ModelCheckpoint, EarlyStopping, CSVLogger\n",
    "from keras.optimizers import SGD, Adam\n",
    "import matplotlib.pyplot as plt\n",
    "import keras.backend as K\n",
    "import utils_paths\n",
    "import numpy as np\n",
    "import cv2 as cv\n",
    "import pickle\n",
    "import os\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "809b5223",
   "metadata": {},
   "outputs": [],
   "source": [
    "INIT_LR = 2e-4\n",
    "EPOCHS = 200\n",
    "batch_size = 8\n",
    "depth = 3\n",
    "img_size = 512\n",
    "Name = \"MTL_IBA_cross3_512\"\n",
    "GPU = True\n",
    "target = (img_size, img_size)\n",
    "\n",
    "if GPU:\n",
    "    os.environ[\"CUDA_DEVICE_ORDER\"] = \"PCI_BUS_ID\"\n",
    "    os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"1\"\n",
    "\n",
    "\n",
    "print(\"------------------------------------------------ Reading data ------------------------------------------------\")\n",
    "#\n",
    "testX_dir = 'dataset/Dataset_BUSI_AN/test/images/'\n",
    "# model = MTL_classic(img_size, img_size, depth, nClasses=2)\n",
    "# model = MTL_IBA_cross(img_size, img_size, depth, nClasses=2)\n",
    "# model = MTL_IBA_cross2(img_size, img_size, depth, nClasses=2)\n",
    "model = MTL_IBA_cross3(img_size, img_size, depth, nClasses=2)\n",
    "model.summary()\n",
    "\n",
    "\n",
    "model.load_weights('MTL_IBA_cross3_512_2e-4.h5', by_name=True)\n",
    "\n",
    "\n",
    "test_x, test_c_y, test_s_y = load_clas_seg_data(testX_dir, target)\n",
    "\n",
    "\n",
    "lb = LabelBinarizer()\n",
    "test_c_y = lb.fit_transform(test_c_y)\n",
    "test_c_y = to_categorical(test_c_y, 2)\n",
    "\n",
    "\n",
    "# define callbacks\n",
    "csv_logger = CSVLogger(Name+'.log')\n",
    "\n",
    "reduce_lr = ReduceLROnPlateau(monitor='classification_output_loss', factor=0.1, patience=10, min_lr=1e-8, mode='auto', verbose=1)\n",
    "\n",
    "checkpoint_period1 = ModelCheckpoint(Name + '-{epoch:03d}-{val_segmentation_output_acc:.4f}.h5',\n",
    "                                     monitor='classification_output_acc', mode='auto', save_best_only='True')\n",
    "\n",
    "checkpoint_period2 = ModelCheckpoint(Name + '-{epoch:03d}-{val_segmentation_output_acc:.4f}.h5',\n",
    "                                     monitor='segmentation_output_loss', mode='auto', period=20)\n",
    "\n",
    "\n",
    "# define loss and compile the model\n",
    "\n",
    "print(\"------------------------------------------------ begin training ------------------------------------------------\")\n",
    "opt = Adam(lr=INIT_LR, beta_1=0.9, beta_2=0.99, epsilon=1e-08, decay=0.01)\n",
    "\n",
    "\n",
    "from keras.losses import categorical_crossentropy\n",
    "\n",
    "# model.compile(loss={'segmentation_output': tversky_loss, \"classification_output\": binary_crossentropy},\n",
    "#               loss_weights={'segmentation_output': 0.3, \"classification_output\": 0.7},\n",
    "#               optimizer=opt,\n",
    "#               metrics={'segmentation_output': ['accuracy', dice_coef], \"classification_output\": ['accuracy']})\n",
    "\n",
    "# \n",
    "# model.compile(loss={'segmentation_output': categorical_crossentropy, 'seg-out': tversky_loss, \"classification_output\": binary_crossentropy},\n",
    "#               loss_weights={'segmentation_output': 0.25,'seg-out': 0.5, \"classification_output\": 0.5},\n",
    "#               optimizer=opt, \n",
    "#               metrics={'segmentation_output':'accuracy', 'seg-out':dice_coef, 'classification_output':'accuracy'})\n",
    "\n",
    "model.compile(loss={'segmentation_output': categorical_crossentropy, 'seg-out': tversky_loss, \"classification_output\": binary_crossentropy},\n",
    "              loss_weights={'segmentation_output': 0.35,'seg-out': 0.35, \"classification_output\": 0.3},\n",
    "              optimizer=opt, \n",
    "              metrics={'segmentation_output':'accuracy', 'seg-out':dice_coef, 'classification_output':'accuracy'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d909345d",
   "metadata": {},
   "outputs": [],
   "source": [
    "print(\"------------------------------------------------class testing ---------------------------------------------------------\")\n",
    "predictions_c, predictions_s, predictions_s2 = model.predict(test_x, batch_size=batch_size)\n",
    "test_c = test_c_y.argmax(axis=1)\n",
    "print(classification_report(test_c_y.argmax(axis=1),\n",
    "      predictions_c.argmax(axis=1),\n",
    "      digits=6))\n",
    "\n",
    "\n",
    "# print(\"------------------------------------------------class testing ---------------------------------------------------------\")\n",
    "# predictions_c, predictions_s = model.predict(test_x, batch_size=batch_size)\n",
    "# test_c = test_c_y.argmax(axis=1)\n",
    "# print(classification_report(test_c_y.argmax(axis=1),\n",
    "#       predictions_c.argmax(axis=1),\n",
    "#       digits=6))\n",
    "\n",
    "'''\n",
    "print(\"------------------------------------------------ Segmentation testing ------------------------------------------------\")\n",
    "\n",
    "# evaluate the model\n",
    "# loss = model.evaluate(test_x, [test_c_y, test_s_y], verbose=0)\n",
    "loss, cla_loss, seg_loss, seg_loss2, cla_acc, seg_acc, seg_dice_coef = model.evaluate(test_x, [test_c_y, test_s_y, test_s_y], verbose=0)\n",
    "print('Test total loss:', loss)\n",
    "print('Test classification loss:', cla_loss)\n",
    "print('Test segmentation loss:', seg_loss)\n",
    "\n",
    "print('Test classification accuracy:', cla_acc)\n",
    "print('Test segmentation accuracy:', seg_acc)\n",
    "print('Test segmentation dice_coef:', seg_dice_coef)\n",
    "\n",
    "\n",
    "preds_c, preds_s, preds_s2 = model.predict(test_x, batch_size=8, verbose=1)\n",
    "test_mask = test_s_y.flatten()\n",
    "pred_mask = preds_s.flatten()\n",
    "fpr, tpr, thresholds = roc_curve(test_mask, pred_mask, pos_label=1)\n",
    "roc_auc = auc(fpr, tpr)\n",
    "print(\"AUC:\", roc_auc)\n",
    "'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "093b9960",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "lw = 2\n",
    "plt.figure(figsize=(10, 10))\n",
    "# ls：折线图的线条风格; lw：折线图的线条宽度; label：标记图内容的标签文本\n",
    "# 假正率为横坐标，真正率为纵坐标做曲线\n",
    "plt.plot(fpr, tpr, color='darkorange', lw=lw, label='ROC curve (area = %0.4f)' % roc_auc)\n",
    "plt.plot([0, 1], [0, 1], color='navy', lw=lw, linestyle='--')\n",
    "plt.xlim([0.0, 1.0])\n",
    "plt.ylim([0.0, 1.05])\n",
    "plt.xlabel('False Positive Rate')\n",
    "plt.ylabel('True Positive Rate')\n",
    "plt.title('ROC curve')\n",
    "# 设置图标\n",
    "# plt.legend(loc=\"lower right\")\n",
    "plt.legend(loc=\"upper right\")\n",
    "plt.show()\n",
    "plt.savefig('VGG_BUSI-ROC.png', dpi=100, transparent=False)\n",
    "\n",
    "# Precision, Recall, accuracy, F1, IoU = p_r_f1_iou(test_s_y, preds_s)\n",
    "# print('Precision:', Precision)\n",
    "# print('Recall:', Recall)\n",
    "# print('m_Iou:', IoU)\n",
    "# print('F1_score:', F1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0611bbc0",
   "metadata": {},
   "source": [
    "## 绘制热力图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "0f4f7cd1",
   "metadata": {},
   "outputs": [],
   "source": [
    "from keras.applications.vgg16 import preprocess_input, decode_predictions\n",
    "from keras.models import load_model, Model\n",
    "from keras.preprocessing import image\n",
    "import matplotlib.pyplot as plt\n",
    "from keras import backend as K\n",
    "import numpy as np\n",
    "import cv2\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "474b7827",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:From /usr/local/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Colocations handled automatically by placer.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2022-04-03 15:16:50.356927: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA\n",
      "2022-04-03 15:16:50.389228: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2200095000 Hz\n",
      "2022-04-03 15:16:50.393643: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x6528ed0 executing computations on platform Host. Devices:\n",
      "2022-04-03 15:16:50.393726: I tensorflow/compiler/xla/service/service.cc:158]   StreamExecutor device (0): <undefined>, <undefined>\n",
      "2022-04-03 15:16:51.094484: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x65d4f10 executing computations on platform CUDA. Devices:\n",
      "2022-04-03 15:16:51.094570: I tensorflow/compiler/xla/service/service.cc:158]   StreamExecutor device (0): Tesla V100-PCIE-32GB, Compute Capability 7.0\n",
      "2022-04-03 15:16:51.095938: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1433] Found device 0 with properties: \n",
      "name: Tesla V100-PCIE-32GB major: 7 minor: 0 memoryClockRate(GHz): 1.38\n",
      "pciBusID: 0000:05:00.0\n",
      "totalMemory: 31.72GiB freeMemory: 30.66GiB\n",
      "2022-04-03 15:16:51.095986: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1512] Adding visible gpu devices: 0\n",
      "2022-04-03 15:16:51.106795: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] Device interconnect StreamExecutor with strength 1 edge matrix:\n",
      "2022-04-03 15:16:51.106902: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990]      0 \n",
      "2022-04-03 15:16:51.106921: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1003] 0:   N \n",
      "2022-04-03 15:16:51.108223: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 29826 MB memory) -> physical GPU (device: 0, name: Tesla V100-PCIE-32GB, pci bus id: 0000:05:00.0, compute capability: 7.0)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:From /usr/local/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py:3445: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Please use `rate` instead of `keep_prob`. Rate should be set to `rate = 1 - keep_prob`.\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "from models.MTL_IBA import MTL_IBA, MTL_IBA_h3, MTL_IBA_cross, MTL_IBA_cross2, MTL_IBA_cross3\n",
    "from models.MLT_net import MTL_classic\n",
    "from models.MTL_Attention import MTL_Attention_model\n",
    "\n",
    "Name =  'MTL_IBA_cross3-2'\n",
    "img_size =224\n",
    "depth = 3\n",
    "testX_dir = 'dataset/Dataset_BUSI_AN/test/images/'\n",
    "save_dir = 'dataset/prediction/Dataset_BUSI_AN/' + Name\n",
    "if not os.path.exists(save_dir):\n",
    "    os.makedirs(save_dir)\n",
    "    \n",
    "    \n",
    "\n",
    "os.environ[\"CUDA_DEVICE_ORDER\"] = \"PCI_BUS_ID\"\n",
    "os.environ[\"CUDA_VISIBLE_DEVICES\"] = \"0\"\n",
    "   \n",
    "model = MTL_IBA_cross3(img_size, img_size, depth, nClasses=2)\n",
    "# model = MTL_Attention_model(img_size, img_size, depth, nClasses=2)\n",
    "model.load_weights('MTL_IBA_cross3-2.h5', by_name=True)\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "e42d9b21",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "09ad9fd1",
   "metadata": {},
   "outputs": [],
   "source": [
    "def load_img_preprocess(img_path, target_size):\n",
    "    img = image.load_img(img_path, target_size=target_size)\n",
    "    img = image.img_to_array(img) \n",
    "    img = np.expand_dims(img, axis=0) # \n",
    "    img = preprocess_input(img) #\n",
    "    return img\n",
    "\n",
    "\n",
    "def gradient_compute(model, img):\n",
    "  \n",
    "    preds = model.predict(img)\n",
    "    num = np.argmax(preds[0]) #\n",
    "    \n",
    "    model2 = Model(inputs=model.input, outputs=model.get_layer('block5_s_conv3').output)\n",
    "\n",
    "    output = model2.output[0][:, num]\n",
    "    last_layer = model2.get_layer('block5_s_conv3')\n",
    "    grads = K.gradients(output, last_layer.output)[0]\n",
    "    pooled_grads = K.mean(grads, axis=(0, 1, 2)) #\n",
    "    iterate = K.function([model2.input], [pooled_grads, last_layer.output[0]])\n",
    "    pooled_grads_value, conv_layer_output_value = iterate([img])\n",
    "\n",
    "    for i in range(pooled_grads.shape[0]):\n",
    "        conv_layer_output_value[:, :, i] *= pooled_grads_value[i]\n",
    "\n",
    "    return conv_layer_output_value\n",
    "\n",
    "def plot_heatmap(conv_layer_output_value, img_in_path, img_out_path):\n",
    "    \n",
    "\n",
    "#     heatmap = np.mean(conv_layer_output_value, axis=-1)\n",
    "    heatmap = np.mean(conv_layer_output_value,axis = -1)\n",
    "    heatmap = np.maximum(heatmap, 0)\n",
    "    heatmap = heatmap / np.max(heatmap)\n",
    "\n",
    "    img = cv2.imread(img_in_path)\n",
    "    heatmap = cv2.resize(heatmap, (img.shape[1], img.shape[0]))\n",
    "    heatmap = np.uint8(255 * heatmap)\n",
    "\n",
    "    heatmap = cv2.applyColorMap(heatmap, cv2.COLORMAP_JET)\n",
    "    superimopsed_img = heatmap * 0.4 + img\n",
    "    \n",
    "    cv2.imwrite(img_out_path, superimopsed_img)\n",
    "    \n",
    "    print(img_out_path)\n",
    "\n",
    "    \n",
    "def plot_dict_img_heatmap(testX_dir, save_dir, model):\n",
    "    \n",
    "    class_list = os.listdir(testX_dir)\n",
    "    for class_name in class_list:\n",
    "        class_path = os.path.join(testX_dir, class_name)\n",
    "        img_list = os.listdir(class_path)\n",
    "        for image_Name in img_list:\n",
    "            \n",
    "            img_path = os.path.join(class_path, image_Name)\n",
    "            print(img_path)\n",
    "            img_out_path = os.path.join(save_dir, image_Name)\n",
    "            \n",
    "            img = load_img_preprocess(img_path, (224, 224))\n",
    "            conv_value = gradient_compute(model, img)\n",
    "            plot_heatmap(conv_value, img_path, img_out_path)\n",
    "            \n",
    "#             plot_heatmap(img_path, save_dir, (512, 512) ,model)\n",
    " "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "2b4430f9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (51).png\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2022-04-03 15:17:28.105921: I tensorflow/stream_executor/dso_loader.cc:152] successfully opened CUDA library libcublas.so.10.0 locally\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (51).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (299).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (299).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (167).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (167).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (220).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (220).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (297).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (297).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (425).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (425).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (57).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (57).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (38).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (38).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (222).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (222).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (372).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (372).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (140).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (140).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (155).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (155).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (321).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (321).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (15).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (15).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (103).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (103).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (154).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (154).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (221).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (221).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (136).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (136).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (187).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (187).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (218).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (218).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (231).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (231).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (127).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (127).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (21).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (21).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (150).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (150).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (315).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (315).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (104).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (104).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (142).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (142).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (119).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (119).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (153).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (153).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (88).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (88).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (388).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (388).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (48).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (48).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (316).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (316).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (81).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (81).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (349).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (349).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (84).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (84).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (364).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (364).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (353).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (353).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (408).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (408).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (324).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (324).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (391).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (391).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (147).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (147).png\n",
      "dataset/Dataset_BUSI_AN/test/images/bengin_images/benign (201).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/benign (201).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (191).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (191).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (170).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (170).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (131).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (131).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (112).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (112).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (190).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (190).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (18).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (18).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (44).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (44).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (200).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (200).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (149).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (149).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (86).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (86).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (123).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (123).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (20).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (20).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (74).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (74).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (121).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (121).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (146).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (146).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (72).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (72).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (171).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (171).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (106).png\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (106).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (45).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (45).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (65).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (65).png\n",
      "dataset/Dataset_BUSI_AN/test/images/malignant_images/malignant (136).png\n",
      "dataset/prediction/Dataset_BUSI_AN/MTL_IBA_cross3-2/malignant (136).png\n"
     ]
    }
   ],
   "source": [
    "\n",
    "# model = load_model_h5(model_path)\n",
    "\n",
    "\n",
    "plot_dict_img_heatmap(testX_dir, save_dir, model)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5020954a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
